package com.eschool.beans.datamodels;

import java.io.Serializable;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

import com.eschool.model.ScheduleSlot;
import com.eschool.model.Student;

public class TimetableDataModel extends ListDataModel<ScheduleSlot> implements SelectableDataModel<ScheduleSlot>, Serializable {  

    public TimetableDataModel() {
    }

    public TimetableDataModel(List<ScheduleSlot> data) {
        super(data);
    }
    
    @Override
    public ScheduleSlot getRowData(String rowKey) {
        List<ScheduleSlot> slots = (List<ScheduleSlot>) getWrappedData();
        
		for (ScheduleSlot slot : slots) {
            if(Integer.toString(slot.getScheduleId()).equals(rowKey))
                return slot;
        }
        
        return null;
    }

    @Override
    public Object getRowKey(ScheduleSlot slot) {
        return slot.getScheduleId();
    }
}